package com.inspur.ssm.dao.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import com.inspur.ssm.dao.UserDao;
import com.inspur.ssm.pojo.UserBean;


@Repository("loginDao")
public class UserDaoImpl implements UserDao{
	
	@Autowired
	private JdbcTemplate jdbcTemplate;
	
	
	public UserBean findManager(UserBean userBean)throws Exception{
		UserBean ruserBean=null;
		Object [] obj=new Object[2];
		obj[0]=userBean.getUserName();
		obj[1]=userBean.getPw();
		List<Map<String,Object>> list=jdbcTemplate.queryForList("select * from user where userName=? and pw=?",obj);
		if(list!=null&&list.size()>0){
			ruserBean=new UserBean();
			for(Map<String,Object> map:list){
				Object userName=map.get("userName");
				Object pw=map.get("pw");
				ruserBean.setUserName(userName.toString());
				ruserBean.setPw(pw.toString());
			}
		}
		return ruserBean;
	}
}
